﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Linq.Expressions;
using System.Data.Objects;
using System.Data.Services;

namespace AstoriaPlus
{
	/// <summary>
	/// Allows setting access rules in a strong-typed fashion. Retrieve this interface by using the 
	/// <see cref="AccessRulesExtensions.AccessRulesFor{T}"/> extension method 
	/// on a configuration object.
	/// </summary>
	public interface IAccessRules<T> : IFluentInterface
	{
		/// <summary>
		/// Sets the entity access rights for the specified entity set property reference.
		/// </summary>
		/// <typeparam name="TEntity">The type of the entity in the set.</typeparam>
		/// <param name="entitySetProperty">A property access expression over a data context of type <typeparamref name="T"/> that represents the entity set to specify the rights for, such as <c>x => x.Users</c>.</param>
		/// <param name="rights">The rights to set.</param>
		void SetRights<TEntity>(Expression<Func<T, IObjectSet<TEntity>>> entitySetProperty, EntitySetRights rights)
			where TEntity : class;

		/// <summary>
		/// Sets the entity access rights for the specified entity set property reference.
		/// </summary>
		/// <typeparam name="TEntity">The type of the entity in the set.</typeparam>
		/// <param name="entitySetProperty">A property access expression over a data context of type <typeparamref name="T"/> that represents the entity set to specify the rights for, such as <c>x => x.Users</c>.</param>
		/// <param name="rights">The rights to set.</param>
		void SetRights<TEntity>(Expression<Func<T, IQueryable<TEntity>>> entitySetProperty, EntitySetRights rights)
			where TEntity : class;
	}
}
